import React, {useEffect, useState} from 'react';
import '@/style/notFound.css'
import {Button} from "antd";

const NotFound = () => {
    const [seconds, setSeconds] = useState(5);
    useEffect(() => {
        const intervalTimer = setInterval(() => {
            setSeconds(prevSeconds => {
                if (prevSeconds < 1) {
                    clearInterval(intervalTimer);
                    window.history.back();
                    return prevSeconds
                }
                return prevSeconds - 1;
            });
        }, 1000);
        return () => {
            intervalTimer && clearInterval(intervalTimer);
        };
    }, []);
    return (
        <div className="error">
            <div className='error-text'>
                <div className="error-code">404</div>
                <div className="error-title">页面不存在</div>
                <Button onClick={() => {
                    window.history.back()
                }} type='primary'>{seconds} 秒后返回上一页</Button>
            </div>
        </div>
    )
};

export default NotFound;